// pages/patientdetail/patientdetail.js
var app = getApp()
Page({
  data: {
    items: [
      { name: '马云', value: '内科主任医师:马云' },
      { name: '李彦宏', value: '内科主任医师:李彦宏\n' },
      { name: '刘强东', value: '妇科医师:刘强东\n' },
      { name: '马化腾', value: '儿科大夫:马化腾\n' },
    ],
    doc:' ',
    select: false,
    department: '医生科室',
  },
  onLoad: function (options) {
  },
  

  radioChange: function (ef) {
    console.log('radio发生change事件，携带value值为：', ef.detail.value)
    this.setData({
      doc: ef.detail.value
    })
    console.log("医生名  "+this.data.doc)
  },


  //var id = this.data.id;
  formSubmit: function (e) {
    var that=this;
    console.log('form发生了submit事件，携带数据为：', e.detail.value);
    var objDate = e.detail.value;
    if (objDate.id && objDate.name && objDate.birth && objDate.height && objDate.weight && objDate.time && this.data.doc) {
      wx.setStorage({
        key: 'id',
        data: objDate.id,
      })
      wx.setStorage({
        key: 'name',
        data: objDate.name,
      })
      wx.setStorage({
        key: 'birth',
        data: objDate.birth,
      })
      wx.setStorage({
        key: 'height',
        data: objDate.height,
      })
      wx.setStorage({
        key: 'weight',
        data: objDate.weight,
      })
      wx.setStorage({
        key: 'time',
        data: objDate.time,
      })
      wx.setStorage({
        key: 'majordoctor',
        data: this.data.doc,
      })
      
      wx.request({
        url: app.globalData.url + '/API/patientinfo',
        data: {
          'id': e.detail.value.id,
          'name': e.detail.value.name,
          'birth': e.detail.value.birth,
          'height': e.detail.value.height,
          'weight': e.detail.value.weight,
          'time': e.detail.value.time,
          'majordoctor': this.data.doc
        },
        method: 'get',
        header: {
          'content-type': 'application/json'
        },
        success: function (res) {
          console.log(res.data)
        }
      })
      wx.redirectTo({
        url: '../homepage/homepage',
      })
    }
  },
  formReset: function () {
    console.log('form发生了reset事件')
  },
  onShareAppMessage: function () {
  }
})
